var mOpenId = "yg_openid";
var mSessionKey = "yg_session_key";

function cacheOpenId(openId) {//缓存openId
    cache(mOpenId, openId);
}

function cacheSessionKey(sessionKey) {//缓存session_key
    cache(mSessionKey, sessionKey);
}

function getOpenId() {
    return getCache(mOpenId);
}

function getSessionKey() {
    return getCache(mSessionKey);
}

function cache(key, value) {
    try {
        wx.setStorageSync(key, value);
    } catch (e) {

    }
}

function getCache(key) {
    var value = null;
    try {
        value = wx.getStorageSync(key);
    } catch (e) {

    }
    return value;
}

module.exports = {
    cacheOpenId: cacheOpenId,
    getOpenId: getOpenId,
    cacheSessionKey: cacheSessionKey,
    getSessionKey: getSessionKey
}